<template>
  <Card  style="height:900px">
  <Card style="width:350px;margin:150px auto">
    <Row type="flex" align="middle">
      <Col span="4">产品:</Col>
      <Col span="18">
      {{productTypeName}}
      </Col>
    </Row>
    <Row type="flex" align="middle">
      <Col span="4">流程:</Col>
      <Col span="18">
      {{flowName}}
      </Col>
    </Row>
    <Row type="flex" align="middle">
      <Col span="4">状态:</Col>
      <Col span="18">
      <Select v-model="status" style="width:200px" >
        <Option v-for="item in statusDatas" :value="item.value" :key="item.value">{{ item.label }}</Option>
      </Select>
      </Col>
    </Row>
    <Row type="flex" align="middle" style="margin-top:20px">
      <Col span="9"></Col>
      <Col span="14">
      <Button type="primary" @click="subProductFlowEdit" size="small">提交</Button>
      </Col>
    </Row>
  </Card>
  </Card>
</template>
<script>

export default {
  data () {
    return {
      productType: null,
      productTypeName: null,
      status: null,
      pdId: null,
      statusDatas: [
        {
          label: '有效',
          value: 0
        },
        {
          label: '无效',
          value: 1
        }
      ],
      flowName: null,
      pfId: null
    }
  },
  computed: {
    type () {
      return this.$route.query.type
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
    // this.initProductType();
    // this.initFlow();
    var pfId = this.$route.params.id
    this.initProductFlow(pfId)
  },
  mounted () {},
  methods: {
    subProductFlowEdit () {
      var params = {}
      // 获取流程名称
      params.status = this.status
      params.productType = this.productType
      params.id = this.pfId
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/manager_pt/service/modify', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.success('操作成功!')
          this.$router.push({
            name: 'product_flow'
          })
        } else {
          this.$Message.error('操作失败!')
        }
      }).catch(er => {
        this.$Message.error('操作失败!')
      })
    },
    // //初始化流程
    // initFlow() {
    //   var params = {};
    //   params.pageSize = 100000;
    //   this.$ajax.post(this.$appContext.marvels_core_approve+'approve/manager/service/query',params)
    //     .then(re => {
    //       var datas = re.data.data.list || [];
    //       this.flowDatas = [];
    //       datas.forEach(item => {
    //         if (item.actKey != null) {
    //           var sData = {};
    //           sData.value = item.actKey;
    //           sData.label = item.actName;
    //           this.flowDatas.push(sData);
    //         }
    //       });
    //     })
    //     .catch(er => {
    //     });
    // },
    // initProductType() {
    //   var params = {};
    //   params.productType = null;
    //   params.version = null;
    //   params.pageSize = 2000;
    //   params.currentPage = 1;

    //   this.$ajax.post(this.$appContext.marvels_core_product+'product/mcpt/service/searchProduct',params)
    //     .then(re => {
    //       var datas = re.data.data.list || [];
    //       this.productTypeDatas = [];
    //       datas.forEach(item => {
    //         var sData = {};
    //         sData.value = item.productType;
    //         sData.label = item.productTypeName;
    //         this.productTypeDatas.push(sData);
    //       });
    //     })
    //     .catch(er => {
    //     });
    // },
    initProductFlow (id) {
      var params = {}
      params.id = id
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/manager_pt/service/id', params).then(re => {
        var data = re.data.data || {}
        this.productType = data.productType
        this.productTypeName = data.productTypeName
        this.flowName = data.actName
        this.status = data.status
        this.pfId = data.id
      }).catch(er => {
      })
    }
  },
  watch: {
    $route (val) {}
  },
  props: {}
}
</script>

<style lang="less">
.xzqy-page {
  /*@media only screen and (min-width:1366px){
      .bottom-btn button:nth-of-type(1){
        margin-right:70px;
      }
    }
    @media only screen and (min-width:1200px){
      .bottom-btn button:nth-of-type(1){
        margin-right:40px;
      }
    }*/
}
</style>
